EXPORT_SYMBOL(unregister_xenstore_notifier);
+static int all_devices_ready_(struct device *dev, void *data)
+{
+ struct xenbus_device *xendev = to_xenbus_device(dev);
+ int *result = data;
+ int state;
+
+ int err = xenbus_scanf(XBT_NULL, xendev->nodename, "state", "%d",
+ &state);
+ if (err != 1 || state != XenbusStateConnected) {
+ result = 0;
+ return 1;
+ }
+
+ return 1;
+}
+
+
+static int all_devices_ready(void)
+{
+ int ready = 1;
+ bus_for_each_dev(&xenbus_frontend.bus, NULL, &ready,
+ all_devices_ready_);
+ return ready;
+}
+
void xenbus_probe(void *unused)
{
+ int i;
+
BUG_ON((xenstored_ready <= 0));
/* Enumerate devices in xenstore. */
/* Notify others that xenstore is up */
notifier_call_chain(&xenstore_chain, 0, NULL);
+
+ /* On a 10 second timeout, waiting for all devices currently
+ configured. We need to do this to guarantee that the filesystems
+ and / or network devices needed for boot are available, before we
+ can allow the boot to proceed.
+
+ A possible improvement here would be to have the tools add a
+ per-device flag to the store entry, indicating whether it is needed
+ at boot time. This would allow people who knew what they were
+ doing to accelerate their boot slightly, but of course needs tools
+ or manual intervention to set up those flags correctly.
+ */
+ for (i = 0; i < 10 * HZ; i++) {
+ if (all_devices_ready())
+ return;
+
+ set_current_state(TASK_INTERRUPTIBLE);
+ schedule_timeout(1);
+ }
+
+ printk(KERN_WARNING
+ "XENBUS: Timeout connecting to devices!\n");
}